<template>
  <div>
    <ul class="mui-table-view">
      <li class="mui-table-view-cell mui-media" v-for="news in newsList" :key="news.id">
        <router-link  :to="'/home/newsList/' + news.id">
          <img class="mui-media-object mui-pull-left" src="../../images/menu2.png" />
          <div class="mui-media-body">
            <h3>{{news.title}}</h3>
            <p class="mui-ellipsis">
              <span>发表时间：{{news.add_time | dataFormat }}</span>
              <span>点击：{{news.click}}次</span>
            </p>
          </div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  data(){
    return {
      newsList:[]
    }
  },
  created(){
    this.getNewsList();
  },
  methods:{
    getNewsList(){
      this.$http.get('/getlist').then(result => {
        console.log(result.body);
        if(result.body){
          this.newsList = result.body;
        }
      }).catch((err) => {
        console.log(err);
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.mui-table-view {
  li {
    h3{
      font-size: 14px;
    }
    .mui-ellipsis{
      font-size: 12px;
      color: #226aff;
      display: flex;
      justify-content: space-between;
    }
  }
}
</style>